import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
// 集成中文
import 'dayjs/locale/zh'

export const timeAgo = (targetTime) => {
  dayjs.extend(relativeTime)
  dayjs.locale('zh')
  const a = dayjs()// 系统的时间
  const b = dayjs(targetTime)
  return a.to(b)
}

export const formatTime = (date) => {
  return dayjs(date).format('YYYY-MM-DD')
}
